package br.com.merks.model;

import java.math.BigDecimal;
import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
@Entity
@NamedQueries({
	@NamedQuery(name="trade.findByMarketAndUser",query="SELECT x FROM br.com.merks.model.Trade x WHERE x.marketId = :marketId AND x.userId = :userId"),
	@NamedQuery(name="trade.findByMarket",query="SELECT x FROM br.com.merks.model.Trade x WHERE x.marketId = :marketId"),
	@NamedQuery(name="trade.findAll",query="SELECT x FROM br.com.merks.model.Trade x")
})
public class Trade {
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Long id;
	private Integer value;
	
	@Temporal(TemporalType.TIMESTAMP)
	private Date timestamp;
	
	private Long marketId;
	private Long userId;
	
	private Long marketAnswerId;
	
	private BigDecimal transactionPrice;
	
	public Trade(Long id, Integer value, Date timestamp, Long marketId,
			Long userId, Long marketAnswerId, BigDecimal transactionPrice,
			BigDecimal merkPrice, OptionType option) {
		super();
		this.id = id;
		this.value = value;
		this.timestamp = timestamp;
		this.marketId = marketId;
		this.userId = userId;
		this.marketAnswerId = marketAnswerId;
		this.transactionPrice = transactionPrice;
		this.merkPrice = merkPrice;
		this.option = option;
	}

	private BigDecimal merkPrice;
	
	private String merkPriceFormated;

	@Enumerated(EnumType.STRING)  
	private OptionType option;
	
	public Long getMarketAnswerId() {
		return marketAnswerId;
	}
	public void setMarketAnswerId(Long marketAnswerId) {
		this.marketAnswerId = marketAnswerId;
	}
	public Trade() { }
	
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public Integer getValue() {
		return value;
	}
	public void setValue(Integer value) {
		this.value = value;
	}
	
	public Long getUserId() {
		return userId;
	}
	public void setUserId(Long userId) {
		this.userId = userId;
	}
	public void setMarketId(Long marketId) {
		this.marketId = marketId;
	}
	public Long getMarketId() {
		return marketId;
	}
	public void setOption(OptionType option) {
		this.option = option;
	}
	public OptionType getOption() {
		return option;
	}
	public void setTimestamp(Date timestamp) {
		this.timestamp = timestamp;
	}
	public Date getTimestamp() {
		return timestamp;
	}
	public BigDecimal getTransactionPrice() {
		return transactionPrice;
	}
	public void setTransactionPrice(BigDecimal transactionPrice) {
		this.transactionPrice = transactionPrice;
	}
	public BigDecimal getMerkPrice() {
		return merkPrice;
	}
	public void setMerkPrice(BigDecimal merkPrice) {
		this.merkPrice = merkPrice;
		
	}
	
	public String getMerkPriceFormated() {
		return merkPriceFormated;
	}
	
}
